﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Configuration;

namespace BpmHsjqYw.ashx
{
    /// <summary>
    /// HSJQ_YHSQ 的摘要说明
    /// 办公用品申请流程处理程序
    /// </summary>
    public class HSJQ_YHSQ : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            //context.Request[""].ToString().Trim();
            string parm = context.Request.Params["type"];
            string strrusult = "";
            string ucode = "";
            string uname = "";
            string sqtime = "";
            string udept = "";
            string lcbh = "";
            string guid = "";
            string sqwp = "";
            string sqsm = "";
            string lxdh = "";
            string strSql = "";
            OracleDBClass oraDB = new OracleDBClass();
            oraDB.ConnStr = ConfigurationManager.AppSettings["UltimusYW"].ToString();
            string tableName = "HSJQ_ZHGL_BGYPSQ";
            switch (parm)
            {
                #region 保存业务数据
                case "1"://保存
                    try
                    {
                        ucode = context.Request["usercode"].ToString().Trim();
                        uname = context.Request["username"].ToString().Trim();
                        sqtime = context.Request["sqtime"].ToString().Trim();
                        udept = context.Request["udept"].ToString().Trim();
                        lcbh = context.Request["lxdh"].ToString().Trim();
                        guid = context.Request["lcbh"].ToString().Trim();
                        sqwp = context.Request["sqwp"].ToString().Trim();
                        sqsm = context.Request["sqsm"].ToString().Trim();
                        lxdh = context.Request["lxdh"].ToString().Trim();
                        BpmHsjqYw.Common.DataHelper newGuid = new BpmHsjqYw.Common.DataHelper();//声明DataHelper
                        guid = newGuid.GetGuid();//获取GUID
                        strSql = "insert into " + tableName
                            + "(id,guid,apply_user_code,apply_user_name,Apply_Dpt,Apply_Date,Processname,Incident,Tel,runnum,sqwp,Sqsm"
                            + ")values(SEQ_" + tableName + ".nextval,'" + guid + "','" + ucode + "','" + uname + "','" + udept
                            + "','" + sqtime + "','办公用品申请流程',0,'" + lxdh + "','" + lcbh + "','" + sqwp + "','" + sqsm + "')";
                        oraDB.exeSql(strSql);
                    }
                    catch (Exception ee)
                    {
                        strrusult = "{\"strrusult\":\"er\"}";//处理异常的话，返回"er"
                        BpmHsjqYw.Common.WriteLog WLog = new Common.WriteLog();
                        WLog.Log("办公用品申请流程", ee.Message);
                    }
                    finally
                    {
                        //返回结果start
                        strrusult = "{\"strrusult\":\"ok\"}";
                        context.Response.Write(strrusult);
                        //返回end
                    }
                    break;
                #endregion
                case "2":
                    break;
                case "3":
                    break;
                case "4":
                    break;
                case "5":
                    break;
                default:
                    break;
            }
        }
        #region 保存业务数据
        private string saveData()
        {

            string aa = "";
            return aa;
        }
        #endregion
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}